package com.attendancesystem.model;



import com.google.gson.annotations.SerializedName;

import java.time.LocalDate;

public class Attendance {
    @SerializedName("attendance_id")
    private Integer attendanceId;
    @SerializedName("student_id")// 考勤ID
    private String studentId;
    @SerializedName("course_name")// 学生ID
    private String courseName;
    @SerializedName("attendance_date")// 课程名称
    private LocalDate attendanceDate; // 考勤日期
    private    Status status;         // 考勤状态

    // 状态枚举
    public enum Status {
        NORMAL("正常"),
        LATE("迟到"),
        ABSENT("缺勤");

        private final String chineseName;

        Status(String chineseName) {
            this.chineseName = chineseName;
        }


        public String getChineseName() {
            return chineseName;
        }
        public static Status fromChineseName(String chineseName) {
            for (Status status : values()) {
                if (status.chineseName.equals(chineseName)) {
                    return status;
                }
            }
            throw new IllegalArgumentException("无效的状态值: " + chineseName);
        }
    }

    // 构造方法
    public Attendance() {}

    public Attendance(String studentId, String courseName,
                      LocalDate attendanceDate, Status status) {
        this.studentId = studentId;
        this.courseName = courseName;
        this.attendanceDate = attendanceDate;
        this.status = status;
    }

    // Getter & Setter
    public Integer getAttendanceId() { return attendanceId; }
    public void setAttendanceId(Integer attendanceId) { this.attendanceId = attendanceId; }

    public String getStudentId() { return studentId; }
    public void setStudentId(String studentId) { this.studentId = studentId; }

    public String getCourseName() { return courseName; }
    public void setCourseName(String courseName) { this.courseName = courseName; }

    public LocalDate getAttendanceDate() { return attendanceDate; }
    public void setAttendanceDate(LocalDate attendanceDate) { this.attendanceDate = attendanceDate; }

    public Status getStatus() { return status; }
    public void setStatus(Status status) { this.status = status; }

    @Override
    public String toString() {
        return "Attendance{" +
                "attendanceId=" + attendanceId +
                ", studentId='" + studentId + '\'' +
                ", courseName='" + courseName + '\'' +
                ", attendanceDate=" + attendanceDate +
                ", status=" + status.getChineseName() +
                '}';
    }
}

